//ssc install reghdfe
//ssc install estout
use "main_prep.dta",replace
graph set window fontface "Garamond"
set scheme white_tableau
//set baseline controls
global control lat lon lnpop_1400 urb_pot uni_12 duni_12  dist_mainz elevationinm suitmean suitstdev river roman growth temp rain war idw_black sea Other



**Figure 1**
graph bar (mean) any_press ,  over(dominican) asyvars  scheme(s1mono) ytitle("Share with printing press") yscale(r(0 (0.1) 0.5)) ylabel(0 (0.1) 0.5) bar(2, color("black")) bar(1, color("gray")) bargap(25) legend(order(1 "No monastery" 2 "Dominican monastery") region(lstyle(none) lcolor(white)) size(*1.2) symxsize(*.6) symysize(*.6) forcesize ring(0) position(11) colgap(tiny) row(1)) title("", color(black))
graph export "intro.pdf", replace

**Table 1**
sum any_press dominican lnpop_1400 growth urb_p uni_12 duni_12 dist_ma Other war idw_bla elevation suitm suits river sea temp rain

**Table 2**
tab dominican any_press if inh_14==1
di 12/845
di 4/74
tab dominican any_press if inh_14>1 & inh_14<6
di 48/598
di 31/160
tab dominican any_press if inh_14>5
di 33/102
di 77/122


**Table 2**
eststo m1: reg any_press dominican,r
estadd local cf "No"
estadd local df "No"
estadd local kf "No"
eststo m2: reghdfe any_press dominican, vce(r) absorb(terr)
estadd local cf "Yes"
estadd local df "No"
estadd local kf "No"
eststo m3: reghdfe any_press dominican $control, vce(r) absorb(terr)
estadd local cf "Yes"
estadd local df "Yes"
estadd local kf "No"
eststo m4: reghdfe any_press dominican $control, vce(r) absorb(grid_id)
estadd local cf "No"
estadd local df "Yes"
estadd local kf "Yes"
esttab m1 m2 m3 m4 using "tab3.tex",replace se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) se(3) b(3) nogaps keep(dominican) coeflabels(dominican "Dominican" )  mtitle("Printing press" "Printing press" "Printing press" "Printing press") s(cf df kf N, label("State FE" "Controls" "Grid FE" "Observations")) nonotes addnotes( ///
    "Note: Estimated using OLS. Robust standard errors in parentheses " ///
    "+ 0.1, * p$<$0.05, ** p$<$0.01, *** p$<$0.001. " )

**Robustness check for later university presence (footnote 3)**
reghdfe any_press dominican $control u1400 duni1400, vce(r) absorb(grid_id)
reghdfe any_press dominican##u1400 $control  duni1400, vce(r) absorb(grid_id)

**Figure 3**
capture drop cat
g cat=0
recode cat (0=1) if fran==1 & domi==0
recode cat (0=2) if domi==1 & fran==0
recode cat (0=3) if domi==1 & fran==1
eststo m3: reghdfe any_press i.cat $control i.terr , vce(r) 
margins,at(cat=(0 1 2 3))
marginsplot, xlabel(0 "None" 1 "Franciscan" 2 "Dominican" 3 "Both") ytitle(Share with printing press) recast(scatter) title("") xtitle(Dominican or Franciscan monastery)

**Tables 4 and A2**
eststo m1: reg university dominican,r
estadd local cf "No"
estadd local df "No"
estadd local kf "No"
eststo m2: reghdfe university dominican, vce(r) absorb(terr)
estadd local cf "Yes"
estadd local df "No"
estadd local kf "No"
eststo m3: reghdfe university dominican $control, vce(r) absorb(terr)
estadd local cf "Yes"
estadd local df "Yes"
estadd local kf "No"
eststo m4: reghdfe university dominican $control, vce(r) absorb(grid_id)
estadd local cf "No"
estadd local df "Yes"
estadd local kf "Yes"
eststo m5: reg any_p university ,r
estadd local cf "No"
estadd local df "No"
estadd local kf "No"
eststo m6: reghdfe any_p university , vce(r) absorb(terr)
estadd local cf "Yes"
estadd local df "No"
estadd local kf "No"
eststo m7: reghdfe any_p university  $control, vce(r) absorb(terr)
estadd local cf "Yes"
estadd local df "Yes"
estadd local kf "No"
eststo m8: reghdfe any_p university  $control, vce(r) absorb(grid_id)
estadd local cf "No"
estadd local df "Yes"
estadd local kf "Yes"
esttab m1 m2 m3 m4  using "tabuni.tex",replace se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) se(3) b(3) nogaps keep(dominican ) coeflabels(dominican "Dominican" university "University, 1216-1400")  mtitle("University, 1216-1400" "University, 1216-1400" "University, 1216-1400" "University, 1216-1400" "Printing press" "Printing press" "Printing press" "Printing press") s(cf df kf N, label("State FE" "Controls" "Grid FE" "Observations")) nonotes addnotes( ///
    "Note: Estimated using OLS. Robust standard errors in parentheses + 0.1, * p$<$0.05, ** p$<$0.01, *** p$<$0.001." )
	esttab m5 m6 m7 m8  using "tabuni_y.tex",replace se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) se(3) b(3) nogaps keep(university) coeflabels(dominican "Dominican" university "University, 1216-1400")  mtitle( "Printing press" "Printing press" "Printing press" "Printing press") s(cf df kf N, label("State FE" "Controls" "Grid FE" "Observations")) nonotes addnotes( ///
    "Note: Estimated using OLS. Robust standard errors in parentheses + 0.1, * p$<$0.05, ** p$<$0.01, *** p$<$0.001." )
	
**Dominicans and non-university schools**
tab school_14  dominican	

**Table 5**
use "nuts2_city_edu.dta",replace
eststo m1: reg education dom_w,r
estadd local cf "No"
estadd local df "No"
eststo m2: reghdfe education dom_w, vce(r) absorb(cd)
estadd local cf "Yes"
estadd local df "No"
eststo m3: reghdfe education dom_w lat lon lnpop_1400 urb_pot  duni_12  dist_mainz elevationinm suitmean suitstdev river roman growth temp rain war idw_black  , vce(r) absorb(cd) 
estadd local cf "Yes"
estadd local df "Yes"
esttab m1 m2 m3 using "tabe.tex",replace se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) se(3) b(3) nogaps keep(dom_w) coeflabels(dom_w "Share with Dominican (population weighted)" )  mtitle("Share ter. edu., age 25-64" "Share ter. edu., age 25-64" "Share ter. edu., age 25-64" ) s(cf df N, label("Country FE" "Controls"  "Observations")) nonotes addnotes( ///
    "Note: Estimated using OLS. Robust standard errors in parentheses + 0.1, * p$<$0.05, ** p$<$0.01, *** p$<$0.001." ///
    "Unit of analysis is NUTS2 region in 2011. All controls are averages across all cities in each NUTS2 region." )
	
***Online appendix***
*********************
**Table A1**
use "main_prep.dta",replace
//per capita
eststo m1: reg press_per_cap dominican,r
estadd local cf "No"
estadd local df "No"
eststo m2: reg press_per_cap dominican i.terr, r
estadd local cf "Yes"
estadd local df "No"
eststo m3: reghdfe press_per_cap dominican $control, vce(r) absorb(terr)
estadd local cf "Yes"
estadd local df "Yes"
//total
eststo m4: reg printing_press dominican,r
estadd local cf "No"
estadd local df "No"
eststo m5: reg printing_press dominican i.terr, r
estadd local cf "Yes"
estadd local df "No"
eststo m6: reghdfe printing_press dominican $control, vce(r) absorb(terr)
estadd local cf "Yes"
estadd local df "Yes"
esttab m1 m2 m3 m4 m5 m6 using "tab_alt_y.tex",replace se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) se(3) b(3) nogaps keep(dominican) coeflabels(dominican "Dominican" )  mtitle("Ln(presses)" "Ln(presses)" "Ln(presses" "Presses per cap." "Presses per cap." "Presses per cap.") s(cf df N, label("State FE" "Controls" "Observations")) nonotes addnotes( ///
    "Note: Estimated using OLS. Robust standard errors in parentheses " ///
    "+ 0.1, * p$<$0.05, ** p$<$0.01, *** p$<$0.001. " )
	
**Table A3**
eststo m1: logit any_press dominican,r
estadd local cf "No"
estadd local df "No"
estadd local kf "No"
eststo m2: logit any_press dominican i.terr, r
estadd local cf "Yes"
estadd local df "No"
estadd local kf "No"
eststo m3: logit any_press dominican $control i.terr, r
estadd local cf "Yes"
estadd local df "Yes"
estadd local kf "No"
eststo m4: logit any_press dominican $control i.grid_id, r
estadd local cf "No"
estadd local df "Yes"
estadd local kf "Yes"
esttab m1 m2 m3 m4 using "tablogit.tex",replace se star(+ 0.1 * 0.05 ** 0.01 *** 0.001) se(3) b(3) nogaps keep(dominican) coeflabels(dominican "Dominican" )  mtitle("Printing press" "Printing press" "Printing press" "Printing press") s(cf df kf N, label("State FE" "Controls" "Grid FE" "Observations")) nonotes addnotes( ///
    "Note: Estimated using Logit. Robust standard errors in parentheses " ///
    "+ 0.1, * p$<$0.05, ** p$<$0.01, *** p$<$0.001. " )
